package com.yiwenup.struct._01_linear.queue;

import com.yiwenup.struct._01_linear.base.List;
import com.yiwenup.struct._01_linear.list.DoublyLinkedList;

/**
 * 队列结构：复用双向链表结构
 */
public class Queue<E> {

    private List<E> list = new DoublyLinkedList<>();

    public int size() {
        return list.size();
    }

    public boolean isEmpty() {
        return list.isEmpty();
    }

    public void enQueue(E ele) {
        list.add(ele);
    }

    public E deQueue() {
        return list.remove(0);
    }

    public E head() {
        return list.get(0);
    }

    public void clear() {
        list.clear();
    }
}
